package com.lc.zpyh.ui.activity.home;

import android.os.Bundle;

import com.flyco.tablayout.SlidingTabLayout;
import com.lc.zpyh.R;
import com.lc.zpyh.adapter.MyFragmentPagerAdapter;
import com.lc.zpyh.app.AppActivity;
import com.lc.zpyh.ui.fragment.home.DiscounNoticeFragment;
import com.lc.zpyh.ui.fragment.home.TransactionNoticeFragment;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;

public class FoodNewsActivity extends AppActivity {
    @BindView(R.id.slidingTabLayout)
    SlidingTabLayout slidingTabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    private MyFragmentPagerAdapter mAdapter;

    private List<String> titles = new ArrayList<>();//title集合

    private List<Fragment> fragments = new ArrayList<>();//碎片集合

    @Override
    protected int getLayoutId() {
        return R.layout.activity_foodnews;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        viewPager.setOffscreenPageLimit(2);
        titles.add("交易通知");
        titles.add("通知");
        titles.add("优惠");

        fragments.add(TransactionNoticeFragment.newInstance("0"));
        fragments.add(TransactionNoticeFragment.newInstance("1"));
        fragments.add(DiscounNoticeFragment.newInstance("2"));
        mAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments, getContext(), titles);
        viewPager.setAdapter(mAdapter);
        slidingTabLayout.setViewPager(viewPager);
    }
}
